package view.component.weapon.bug_stick
{
	import enums.main.UISize;
	
	import feathers.controls.Label;
	import feathers.data.ListCollection;
	
	import model.vo.weapon.BugStickMotionVo;
	
	import view.component.BaseSCListView;
	import view.render.weapon.BugStickMotionItem;
	
	
	/**
	 * 操虫棍-动作值列表界面
	 * @author £iang
	 * 
	 */	
	public class BugStickMotionView extends BaseSCListView
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** 动作值标题 */
		public var motionNumTitle:Label;
		/** 物理补正标题 */
		public var physicalAddTitle:Label;
		/** 属性补正标题 */
		public var attriAddTitle:Label;
		/** 备注标题 */
		public var psTitle:Label;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 初始化函数 
		 * 
		 */		
		override protected function initialize():void
		{ 
			_itemH = UISize.GREAT_SWORD_MOTION_ITEM_H * this.dpiScale;
			_listH = UISize.MAIN_H - 
				( UISize.MONSTER_TAB_AREA_H * 2 + 
					UISize.LIST_TITLE_H) * this.dpiScale;
			_scrollerMaxPage = 1;
			_firstName = "动作名";
			super.initialize();
		}
		
		override protected function initializeOther():void
		{
			super.initializeOther();
			motionNumTitle = new Label();
			motionNumTitle.text = "动作值";
			scollerContainer.addChild( motionNumTitle );
			
			physicalAddTitle = new Label();
			physicalAddTitle.text = "物理补正";
			scollerContainer.addChild( physicalAddTitle );
			
			attriAddTitle = new Label();
			attriAddTitle.text = "属性补正";
			scollerContainer.addChild( attriAddTitle );
			
			psTitle = new Label();
			psTitle.text = "备注";
			scollerContainer.addChild( psTitle );
		}
		
		/**
		 * 绘制函数 
		 * 
		 */		
		override protected function draw():void
		{
			var labelY:Number = ( UISize.LIST_TITLE_H - 
				43 ) / 2 * this.dpiScale;
			var leftPadding:Number = UISize.TITLE_PADDING_LEFT * this.dpiScale;
			var firstLabelFullW:Number;
			
			firstTitle.y = labelY;
			firstTitle.x = leftPadding;
			firstLabelFullW = UISize.MAIN_W * 0.4;
			firstTitle.width = firstLabelFullW - leftPadding;
			
			scollerContainer.x = firstLabelFullW;
			scollerContainer.width = UISize.MAIN_W - firstLabelFullW;
			scollerContainer.height = UISize.LIST_TITLE_H;
			
			motionNumTitle.y = labelY;
			motionNumTitle.x = 0;
			motionNumTitle.width  = UISize.MAIN_W * 0.3;
			
			physicalAddTitle.y = labelY;
			physicalAddTitle.x = UISize.MAIN_W * 0.3;
			physicalAddTitle.width  = UISize.MAIN_W * 0.3;
			
			attriAddTitle.y = labelY;
			attriAddTitle.x = UISize.MAIN_W * 0.6;
			attriAddTitle.width  = UISize.MAIN_W * 0.3;
			
			psTitle.y = labelY;
			psTitle.x = UISize.MAIN_W * 0.9;
			psTitle.width  = UISize.MAIN_W * 0.3;
			
			var buttonY:Number = ( UISize.LIST_TITLE_H * this.dpiScale - leftButton.height ) / 2;
			
			leftButton.x = firstLabelFullW - leftButton.width;
			leftButton.y = buttonY;
			
			rightButton.x = UISize.MAIN_W - leftButton.width;
			rightButton.y = buttonY;
			
			list.y = UISize.LIST_TITLE_H * this.dpiScale;
		}
		
		/**
		 * 设置列表数据 
		 * @param dataVec 数据
		 * 
		 */		
		public function setListData( dataVec:Vector.<BugStickMotionVo> ):void
		{
			var i:int;
			var len:int = dataVec.length;
			
			_listData = new ListCollection([]);
			
			for( i = 0; i < len; i++)
			{
				var item:BugStickMotionItem = new BugStickMotionItem();
				var tmpData:BugStickMotionVo = dataVec[ i ] as BugStickMotionVo;
				
				item.setData( tmpData );
				_listData.push( { item:item, itemData:tmpData } );
			}
			
			list.dataProvider = _listData;
		}
		
		//-----------------------------
		// events
		//-----------------------------
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 析构函数 
		 * 
		 */		
		protected override function disposeAnythingInContainer():void
		{
			disposeLabels( [
				"motionNum", "physicalAdd",
				"attriAdd", "ps"
			] );
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function BugStickMotionView()
		{
			super();
		}
	}
}